package com.sky.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sky.dto.ClassPageQueryDTO;
import com.sky.entity.Clazz;
import com.sky.mapper.ClazzMapper;
import com.sky.result.PageResult;
import com.sky.service.ClazzService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
@RequiredArgsConstructor
public class ClazzServiceImpl extends ServiceImpl<ClazzMapper, Clazz> implements ClazzService {

    private final ClazzMapper clazzMapper;

    @Override
    public PageResult pageQuery(ClassPageQueryDTO classPageQueryDTO) {
        PageHelper.startPage(classPageQueryDTO.getPage(), classPageQueryDTO.getPagesize());
        Page<Clazz> page = clazzMapper.queryPage(classPageQueryDTO);
        long total = page.getTotal();
        List<Clazz> records = page.getResult();
        return new PageResult(total, records);
    }


}
